﻿/*
 *  Copyright 2009 Coditate Software
 *  Licensed under the GNU Library General Public License (LGPL) 2.1 
 *  
 *  License available at: http://simplesavant.codeplex.com/license
 */
using System;

namespace Coditate.Savant.Async
{
    /// <summary>
    /// Base class for results returned from <see cref="AsyncExtensions"/> methods.
    /// </summary>
    /// <seealso cref="AsyncAction"/>
    /// <seealso cref="AsyncFunction{R}"/>
    public abstract class AsyncOperation
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="AsyncOperation"/> class.
        /// </summary>
        /// <param name="savant">The savant.</param>
        protected AsyncOperation(ISimpleSavant savant)
        {
            Savant = savant;
        }

        /// <summary>
        /// Gets or sets the savant instance on which an asynchronous call was made.
        /// </summary>
        /// <value>The savant.</value>
        internal ISimpleSavant Savant { get; private set; }

        /// <summary>
        /// Gets a value indicating whether this instance is completed.
        /// </summary>
        /// <value>
        /// 	<c>true</c> if this instance is completed; otherwise, <c>false</c>.
        /// </value>
        public bool IsCompleted
        {
            get { return Result.IsCompleted; }
        }

        /// <summary>
        /// Gets or sets the operation result.
        /// </summary>
        /// <value>The result.</value>
        protected internal IAsyncResult Result { get; protected set; }
    }
}